package com.example.crud.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.crud.mapper.GradeMapper;
import com.example.crud.model.Grade;
import com.example.crud.service.GradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * ClassName: GradeController
 * Package: com.example.crud.controller
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-01-15
 * Time: 20:28
 */
@RestController
@RequestMapping("/grade")
public class GradeController {

    @Autowired
    private GradeMapper gradeMapper;

    @Autowired
    private GradeService gradeService;

    //分页带条件查询
    @RequestMapping("/page/{pageNo}/{pageSize}")
    public IPage<Grade> list(
            @PathVariable Integer pageNo,
            @PathVariable Integer pageSize,
            String gradeName
    ){
        //设置分页信息
        Page<Grade> page = new Page<>(pageNo,pageSize);
        //分页查询 调用服务层方法 传入分页信息 和 查询条件
        IPage<Grade> iPage = gradeService.getGradeByOpr(page,gradeName);

        return iPage;

    }


}
